local sk__zhishi = fk.CreateSkill {

  name = "sk__zhishi",

  tags = {},

}



sk__zhishi:addEffect("active", {
  name = "sk__zhishi",
  anim_type = "special",
  card_num = 3,
  target_num = 0,
  prompt = "#sk__zhishi",
  expand_pile = "sk__xinxianying_jian",
  can_use = function(self, player)
    return #player:getPile("sk__xinxianying_jian") > 2
  end,
  target_filter = Util.FalseFunc,
  card_filter = function(self, player, to_select, selected)
    return #selected < 3 and player:getPileNameOfId(to_select) == "sk__xinxianying_jian" and
        table.every(selected, function(id)
          return Fk:getCardById(to_select).suit ~= Fk:getCardById(id).suit and
          Fk:getCardById(to_select).suit ~= Card.NoSuit
        end)
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    room:moveCardTo(effect.cards, Card.DiscardPile, nil, fk.ReasonPutIntoDiscardPile, sk__zhishi.name, nil, true,
      player.id)
    if player.dead then return end
    player:drawCards(3, sk__zhishi.name)
    if player.dead then return end
    local skills = {}
    for _, general in ipairs(room.general_pile) do
      local g = Fk.generals[general]
      if g.kingdom == "wei" then
        table.insert(skills, g:getSkillNameList())
      end
    end
    skills = table.filter(table.random(skills), function(s)
      return not player:hasSkill(s, true)
    end)
    if #skills == 0 then return end
    room:handleAddLoseSkills(player, skills, nil, true, false)
  end,
})

return sk__zhishi
